package com.im.controller;
import com.im.entity.ImSession;
import com.im.entity.dto.SessionDTO;
import com.im.grpc.GrpcClientService;
import com.im.service.IImSessionService;
import com.im.utils.UserContext;
import com.im.web.response.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author im
 * @since 2025-01-30
 */
@Tag(name = "会话信息模块")
@RestController
@RequestMapping("/link-IM/im-session")
public class ImSessionController {

    @Autowired
    private IImSessionService imSessionService;
    //创建单聊会话
    @Operation(summary = "创建单聊会话")
    @PostMapping("/create/private/session")
    public Result<Object> createPrivateSession(@RequestBody SessionDTO sessionDTO) {
       //返回会话ID
        Long sessionId=imSessionService.createPrivateSession(sessionDTO);
        return Result.success(sessionId);
    }
    //创建群聊会话
    @Operation(summary = "创建群聊会话")
    @PostMapping("/create/group/session")
    public Result<Object> createGroupSession(@RequestBody SessionDTO sessionDTO) {
        //返回会话ID
        Long sessionId=imSessionService.createGroupSession(sessionDTO);
        return Result.success(sessionId);
    }
    //获取会话列表
    @Operation(summary = "获取当前用户的会话列表")
    @PostMapping("/get/session/list")
    public Result<List<ImSession>> getSessionList() {
        List<ImSession> sessions=imSessionService.getSessionList(UserContext.getUser().getUserId());
        return Result.success(sessions);
    }
    //获取会话详情

    //更新会话信息

    //删除会话
}

